package org.jeecg.modules.online.config.service.p023a;

import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.online.cgform.consts.ExtendJsonKey;
import org.jeecg.modules.online.cgform.utils.CgformUtil;
import org.jeecg.modules.online.config.p022d.ColumnMeta;
import org.jeecg.modules.online.config.p022d.DataBaseConst;
import org.jeecg.modules.online.config.service.DbTableHandleI;

/* renamed from: org.jeecg.modules.online.config.service.a.g */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/config/service/a/g.class */
public class DbTableSQLServerHandleImpl implements DbTableHandleI {
    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getAddColumnSql(ColumnMeta columnMeta) {
        return " ADD  " + m2a(columnMeta) + ";";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getReNameFieldName(ColumnMeta columnMeta) {
        return "  sp_rename '" + columnMeta.getTableName() + "." + columnMeta.getOldColumnName() + "', '" + columnMeta.getColumnName() + "', 'COLUMN';";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getUpdateColumnSql(ColumnMeta cgformcolumnMeta, ColumnMeta datacolumnMeta) {
        return " ALTER COLUMN  " + m1a(cgformcolumnMeta, datacolumnMeta) + ";";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getMatchClassTypeByDataType(String dataType, int digits) {
        String str = "";
        if (DataBaseConst.f581l.equalsIgnoreCase(dataType) || "nvarchar".equalsIgnoreCase(dataType)) {
            str = "string";
        } else if ("float".equalsIgnoreCase(dataType)) {
            str = "double";
        } else if ("int".equalsIgnoreCase(dataType)) {
            str = "int";
        } else if ("Datetime".equalsIgnoreCase(dataType)) {
            str = "datetime";
        } else if ("numeric".equalsIgnoreCase(dataType)) {
            str = "bigdecimal";
        } else if ("varbinary".equalsIgnoreCase(dataType) || "image".equalsIgnoreCase(dataType)) {
            str = "blob";
        } else if (ExtendJsonKey.f133f.equalsIgnoreCase(dataType) || "ntext".equalsIgnoreCase(dataType)) {
            str = ExtendJsonKey.f133f;
        }
        return str;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String dropTableSQL(String tableName) {
        return " DROP TABLE " + tableName + " ;";
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getDropColumnSql(String fieldName) {
        return " DROP COLUMN " + fieldName + ";";
    }

    /* renamed from: a */
    private String m1a(ColumnMeta columnMeta, ColumnMeta columnMeta2) {
        String str = "";
        if ("string".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " nvarchar(" + columnMeta.getColumnSize() + ") " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("date".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " datetime " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("datetime".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " datetime " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("int".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " int " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("double".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " float " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("bigdecimal".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " numeric(" + columnMeta.getColumnSize() + CgformUtil.f233E + columnMeta.getDecimalDigits() + ") " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if (ExtendJsonKey.f133f.equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " ntext " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("blob".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " image";
        }
        return str;
    }

    /* renamed from: a */
    private String m2a(ColumnMeta columnMeta) {
        String str = "";
        if ("string".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " nvarchar(" + columnMeta.getColumnSize() + ") " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("date".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " datetime " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("datetime".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " datetime " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("int".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " int " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("double".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " float " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("bigdecimal".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " numeric(" + columnMeta.getColumnSize() + CgformUtil.f233E + columnMeta.getDecimalDigits() + ") " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if (ExtendJsonKey.f133f.equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " ntext " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("blob".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " image";
        }
        return str;
    }

    /* renamed from: b */
    private String m0b(ColumnMeta columnMeta) {
        String str = "";
        if ("string".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " nvarchar(" + columnMeta.getColumnSize() + ") " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("date".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " datetime " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("datetime".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " datetime " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("int".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " int " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        } else if ("double".equalsIgnoreCase(columnMeta.getColunmType())) {
            str = columnMeta.getColumnName() + " float " + ("Y".equals(columnMeta.getIsNullable()) ? "NULL" : "NOT NULL");
        }
        return str;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getCommentSql(ColumnMeta columnMeta) {
        StringBuffer stringBuffer = new StringBuffer("EXECUTE ");
        if (oConvertUtils.isEmpty(columnMeta.getOldColumnName())) {
            stringBuffer.append("sp_addextendedproperty");
        } else {
            stringBuffer.append("sp_updateextendedproperty");
        }
        stringBuffer.append(" N'MS_Description', '");
        stringBuffer.append(columnMeta.getComment());
        stringBuffer.append("', N'SCHEMA', N'dbo', N'TABLE', N'");
        stringBuffer.append(columnMeta.getTableName());
        stringBuffer.append("', N'COLUMN', N'");
        stringBuffer.append(columnMeta.getColumnName() + CgformUtil.f231C);
        return stringBuffer.toString();
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String getSpecialHandle(ColumnMeta cgformcolumnMeta, ColumnMeta datacolumnMeta) {
        return null;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String dropIndexs(String indexName, String tableName) {
        return "DROP INDEX " + indexName + CgformUtil.f206d + tableName;
    }

    @Override // org.jeecg.modules.online.config.service.DbTableHandleI
    public String countIndex(String indexName, String tableName) {
        return "SELECT count(*) FROM sys.indexes WHERE object_id=OBJECT_ID('" + tableName + "') and NAME= '" + indexName + CgformUtil.f231C;
    }
}
